#!/bin/bash
metric=$*
lines=""
args=
while read -t 1 arg || [[ -n ${arg} ]]
do
 if [ -n "$arg" ];then
    if [ -n "$args" ];then
        args=$args";"$arg
    else
        args=$arg
    fi
fi
done

if [[ $args == *rm* ]] || [[ $args == *kill* ]]
   then
   echo "脚本中包含rm或者kill字符"
   exit -1 
fi

lines=`eval $args`
if  [ $? -ne 0 ]; then
  exit -1 
fi

if [ ${lines}x == 'x' ]; then
  lines=0
fi
tags=`echo $monitortag`
endpoint=`hostname |sed 's/w-//g'`
cur_sec=`date '+%s'`
metricData="[{\"metric\":\"$metric\",\"timestamp\":$cur_sec,\"value\":$lines,\"endpoint\":\"$endpoint\",\"tags\":\"$tags\"}]"
echo "$metricData"
